Skip to content

upstream: partition hosts in a single pass#6440

Merged
snowp merged 10 commits intoenvoyproxy:masterfrom
snowp:partition-perf
Apr 16, 2019
Merged

upstream: partition hosts in a single pass#6440
snowp merged 10 commits intoenvoyproxy:masterfrom
snowp:partition-perf

Conversation

@snowp
Copy link
Contributor

@snowp snowp commented Mar 31, 2019

This fixes a performance regression that was introduced when support for
degraded hosts was added: the list of hosts would be iterated over four
times instead of the previous two (one for the hosts list, one for the
hosts per locality list). This PR changes both partition operations to
only iterate over the list of hosts once.

Signed-off-by: Snow Pettersen snowp@squareup.com

Risk Level: Low
Testing: Existing UTs
Docs Changes: n/a
Release Notes: n/a

Snow Pettersen added 2 commits March 30, 2019 17:28
This fixes a performance regression that was introduced when support for
degraded hosts was added: the list of hosts would be iterated over four
times instead of the previous two (one for the hosts list, one for the
hosts per locality list). This PR changes both partition operations to
only iterate over the list of hosts once.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@mattklein123 mattklein123 self-assigned this Apr 1, 2019
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good. A few small comments for thought.

/wait

HostsPerLocalityImpl::filter(std::function<bool(const Host&)> predicate) const {
auto* filtered_clone = new HostsPerLocalityImpl();
HostsPerLocalityConstSharedPtr shared_filtered_clone{filtered_clone};
return filter(std::vector<std::function<bool(const Host&)>>{predicate})[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just get rid of this variant and have callers use the vector version? It doesn't seem worth it to me to maintain both, but I don't feel strongly about it if you do. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i'll just remove this

// We keep two lists: one for being able to mutate the clone and one for returning to the caller.
// Creating them both at the start avoids iterating over the mutable values at the end to convert
// them to a const pointer.
std::vector<HostsPerLocalityImpl*> mutable_clones;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little odd that we are using a raw pointer for this vector. Can we use a shared_ptr here also? I think a mutable shared pointer can be shared ptr casted to const so this should work but not 100% sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give it a go

Host::Health);
// Partitions the provided list of hosts into two new lists containing the healthy and degraded
// hosts respectively.
static std::pair<HostVectorConstSharedPtr, HostVectorConstSharedPtr>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth doing the same type tricks you did previously to make it more clear that the first is healthy and the second is degraded? I think this might be worth it in the this case?

@stale
Copy link

stale bot commented Apr 8, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added stale stalebot believes this issue/PR has not been touched recently and removed stale stalebot believes this issue/PR has not been touched recently labels Apr 8, 2019
Snow Pettersen added 4 commits April 13, 2019 11:58
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Snow Pettersen added 3 commits April 13, 2019 18:40
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I would merge master to pick up flake fixes.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
@snowp
Copy link
Contributor Author

snowp commented Apr 15, 2019

/retest

@repokitteh-read-only
Copy link

🙀 Error while processing event:

evaluation error
error: function http error: Post https://circleci.com/api/v1.1/project/github/envoyproxy/envoy/199220/retry?circle-token=57b4b7966a75db7541e68405ceffb9ffae846ef9: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
🐱

Caused by: a #6440 (comment) was created by @snowp.

see: more, trace.

@snowp snowp merged commit 7dad4a1 into envoyproxy:master Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants